package nowcoder.hw.hj20;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String s = null;
        while ((s = bufferedReader.readLine()) != null) {
            if (s.length() < 9 || !checkCode(s))
                System.out.println("NG");
            else
                System.out.println("OK");
        }
    }


    private static boolean checkCode(String s) {
        String num = ".*\\d.*", lower = ".*[a-z].*", upper = ".*[A-Z].*", others = ".*[^a-zA-Z0-9].*";
        int cnt = 0;
        if (s.matches(num)) cnt++;
        if (s.matches(lower)) cnt++;
        if (s.matches(upper)) cnt++;
        if (s.matches(others)) cnt++;
        return cnt >= 3 && !repeat(s);

    }

    private static boolean repeat(String s) {
        for (int i = 0; i < s.length() - 3; i++) {
            if (s.substring(i + 3).contains(s.substring(i, i + 3))) {
                return true;
            }
        }
        return false;
    }
}